package com.belf.console.domain.entity;

/**
 * 定义数据库的各种对象类型
 */
public enum DbObjectType {
    TABLE("table"),
    VIEW("view"),
    PROCEDURE("procedure"),
    FUNCTION("function"),
    TRIGGER("trigger"),
    TYPE("type"),
    SEQUENCE("sequence"),
    FOREIGN_KEY("foreign_key"),
    SYNONYM("synonym"),
    INDEX("index"),
    ALL("all");

    private String typeName;

    DbObjectType(String typeName) {
        this.typeName = typeName;
    }

    public String getTypeName() {
        return typeName;
    }

    public static DbObjectType getDbObjectType(String typeName) {
        for (DbObjectType type : DbObjectType.values()) {
            if (type.getTypeName().equals(typeName)) {
                return type;
            }
        }
        return TABLE;
    }

    public String chineseName() {
        switch (this) {
            case VIEW: return "视图";
            case PROCEDURE: return "存储过程";
            case FUNCTION: return "函数";
            case TRIGGER: return "触发器";
            case TYPE: return "自定义类型";
            case SEQUENCE: return "序列";
            case FOREIGN_KEY: return "外键";
            case SYNONYM: return "同义词";
            case INDEX: return "索引";
            default:
                return "表";
        }
    }
}
